package week5;
import java.util.*;
public class Day1 {
    //day25_5.13
    //1.笨小猴
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s = in.nextLine();
            int[] map = new int[26];
            for(int i=0;i<s.length();i++) map[(int)(s.charAt(i)) - 97]++;
            int max=0;
            int min=999;
            for(int i=0;i<26;i++) {
                if(map[i]!=0 && map[i]<min) min=map[i];
                if(map[i]!=0 && map[i]>max) max=map[i];
            }
            int ret = max-min;
            int i=2;
            for(;i<ret;i++) if(ret%i==0) break;
            if(i!=ret && ret!=2 || ret == 0 ) {
                System.out.println("No Answer");
                System.out.println("0");
            }
            else {
                System.out.println("Lucky Word");
                System.out.println(ret);
            }
        }
    }
    //2.主持人调度(一)
    public static void main22(String[] args) {
        int[][] arr = {{0,10},{10,20},{20,30}};
        //int[][] arr = {{0,10},{10,20},{15,30}};
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> tmp = new ArrayList<>();
        tmp.add(0);
        tmp.add(10);
        ret.add(tmp);
        List<Integer> tmp2 = new ArrayList<>();
        tmp2.add(10);
        tmp2.add(20);
        ret.add(tmp2);

        List<Integer> tmp3 = new ArrayList<>();
        tmp3.add(20);
        tmp3.add(30);
        ret.add(tmp3);
        System.out.println();
        List<Integer> a = ret.get(0);
        List<Integer> b = ret.get(1);
        System.out.println(a.get(0));
        System.out.println(b.get(1));


        System.out.println(hostschedule(ret));
    }
    public static boolean hostschedule (List<List<Integer>> schedule) {
        // write code here
        int n = schedule.size();//n个活动
        boolean bools = true;
        for(int i=1;i<n;i++) {
            if(schedule.get(i).get(0)< schedule.get(i-1).get(1)) bools=false;
        }
        return true;
    }
    //3.分割等和子集
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n];
            for(int i=0;i<n;i++) arr[i]=in.nextInt();
            Arrays.sort(arr);
            int left=0,right=n-1;
            int sum1 = arr[left++];
            int sum2 = arr[right--];
            while(left<=right) {
                if(sum1<sum2) {
                    sum1+=arr[left++];
                }else if(sum1>sum2){
                    sum2+=arr[right--];
                }
            }
            System.out.println(sum1==sum2?true:false);
        }
    }

}
